.\" Copyright (c) 2000
.\"	Matthew Jacob <mjacob@FreeBSD.org>.  All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\"    notice, this list of conditions and the following disclaimer.
.\"
.\" 2. Redistributions in binary form must reproduce the above copyright
.\"    notice, this list of conditions and the following disclaimer in the
.\"    documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.Dd November 12, 2019
.Dt SES 4
.Os
.Sh NAME
.Nm ses
.Nd SCSI Environmental Services driver
.Sh SYNOPSIS
.Cd device ses
.Sh DESCRIPTION
The
.Nm
driver provides support for all
.Tn SCSI
devices of the environmental services class that are attached to the system
through a supported
.Tn SCSI
Host Adapter, as well as emulated support for SAF-TE (SCSI Accessible
Fault Tolerant Enclosures).
The environmental services class generally are enclosure devices that
provide environmental information such as number of power supplies (and
state), temperature, device slots, and so on.
.Pp
A
.Tn SCSI
Host
adapter must also be separately configured into the system
before a
.Tn SCSI
Environmental Services device can be configured.
.Sh KERNEL CONFIGURATION
It is only necessary to explicitly configure one
.Nm
device; data structures are dynamically allocated as devices are found
on the
.Tn SCSI
bus.
.Pp
A separate option,
.Va SES_ENABLE_PASSTHROUGH ,
may be specified to allow the
.Nm
driver to perform functions on devices of other classes that claim to
also support
.Nm
functionality.
.Sh IOCTLS
The following
.Xr ioctl 2
calls apply to
.Nm
devices.
They are defined in the header file
.In cam/scsi/scsi_enc.h
(\fIq.v.\fR).
.Bl -tag -width ENCIOC_GETENCSTAT
.It Dv ENCIOC_GETNELM
Used to find out how many
.Nm
elements are driven by this particular device instance.
.It Dv ENCIOC_GETELMMAP
Read, from the kernel, an array of SES elements which contains
the element identifier, which subenclosure it is in, and the
.Nm
type of the element.
.It Dv ENCIOC_GETENCSTAT
Get the overall enclosure status.
.It Dv ENCIOC_SETENCSTAT
Set the overall enclosure status.
.It Dv ENCIOC_GETELMSTAT
Get the status of a particular element.
.It Dv ENCIOC_SETELMSTAT
Set the status of a particular element.
.It Dv ENCIOC_GETTEXT
Get the associated help text for an element (not yet implemented).
.Nm
devices often have descriptive text for an element which can tell
you things like location (e.g., "left power supply").
.It Dv ENCIOC_INIT
Initialize the enclosure.
.It Dv ENCIOC_GETELMDESC
Get the element's descriptor string.
.It Dv ENCIOC_GETELMDEVNAMES
Get the device names, if any, associated with this element.
.It Dv ENCIOC_GETSTRING
Used to read the SES String In Diagnostic Page.
The contents of this page are device-specific.
.It Dv ENCIOC_SETSTRING
Used to set the SES String Out Diagnostic Page.
The contents of this page are device-specific.
.It Dv ENCIOC_GETENCNAME
Used to get the name of the enclosure.
.It Dv ENCIOC_GETENCID
Used to get the Enclosure Logical Identifier.
.El
.Sh EXAMPLE USAGE
The files contained in
.In /usr/share/examples/ses
show simple mechanisms for how to use these interfaces, as well as a
very stupid simple monitoring daemon.
.Sh FILES
.Bl -tag -width /dev/rsdXXXXX -compact
.It Pa /dev/ses Ns Ar N
The
.Em Nth
.Nm SES
device.
.El
.Sh DIAGNOSTICS
When the kernel is configured with
.Tn DEBUG
enabled, the first open to an SES device will spit out overall enclosure
parameters to the console.
.Sh SEE ALSO
.Xr sesutil 8
.Sh HISTORY
The
.Nm
driver was originally written for the
.Tn CAM
.Tn SCSI
subsystem by Matthew Jacob and first released in
.Fx 4.3 .
It was a functional equivalent of a similar
driver available in Solaris, Release 7.
It was largely rewritten by Alexander Motin, Justin Gibbs, and Will Andrews for
.Fx 9.2 .
